<%@ page contentType="text/html; charset=utf-8" language="java" errorPage="" %>
<%@ page import="javax.naming.Context"%> 
<%@ page import="javax.sql.DataSource"%> 
<%@ page import="javax.naming.InitialContext"%> 
<%@ page import="java.sql.*"%> 
<%@page import="dataconn.dataconn"%> 

<html> 
<body> 
<%
request.setCharacterEncoding("utf-8");
String ParentName=request.getParameter("select"); 
String ModuleName=request.getParameter("ModuleName");
int ProjectID=Integer.parseInt(request.getParameter("ProjectID"));
dataconn con=new dataconn();

if (ParentName.equals("/"))
{
String sql="insert into TestModule(ModuleName,ProjectID,ParentID,AddedByID) values('"+ModuleName+"','"+ProjectID+"','0',1)";
con.executeUpdate(sql);

}
else
{
String sql="select ModuleID from TestModule where ModuleName='"+ParentName +"'";


ResultSet rs=con.executeQuery(sql); 

if(rs.next())
{
int ParentID=rs.getInt("ModuleID");
sql="insert into TestModule(ModuleName,ProjectID,ParentID,AddedByID) values('"+ModuleName+"','"+ProjectID+"','"+ParentID+"','1')";
con.executeUpdate(sql);
}
}
response.sendRedirect("ManageProject.jsp?ProjectID="+ProjectID);
%> 


  </body>
</html>